//-----------------------------------------------------------------------
// <copyright file="CatalogService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class CatalogService
    {
        #region Catalog

        public static void CreateCatalog(Catalog catalog)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                catalogDAO.CreateCatalog(catalog);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateCatalogException, ex);
            }
        }        

        public static void UpdateCatalog(Catalog catalog)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                catalogDAO.UpdateCatalog(catalog);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateCatalogException, ex);
            }
        }        

        public static void DeleteCatalog(long catalogId)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                catalogDAO.DeleteCatalog(catalogId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteCatalogException, ex);
            }
        }
        
        public static Catalog GetCatalog(long catalogId)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                return catalogDAO.GetCatalog(catalogId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCatalogException, ex);
            }
        }                

        public static CatalogCollection GetCatalogList(CatalogColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                return catalogDAO.GetCatalogList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCatalogListException, ex);
            }
        }        

        public static CatalogCollection GetCatalogList(CatalogColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                return catalogDAO.GetCatalogList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCatalogListException, ex);
            }
        }        

	    public static CatalogCollection GetCatalogListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                return catalogDAO.GetCatalogListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCatalogListException, ex);
            }
        }        

        public static CatalogCollection GetCatalogListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                CatalogDAO catalogDAO = new CatalogDAO();
                return catalogDAO.GetCatalogListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCatalogListException, ex);
            }
        }        

        #endregion
    }
}